package Vue;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.FlowLayout;
import java.awt.Color;
import javax.swing.JButton;
import Controleur.MainFrame_BtnListener;

/**
 * Définit la fenêtre et le programme principal
 */
public class MainFrame extends JFrame {

	
	private static final long serialVersionUID = 1L;
	/** Conteneur graphique */
	private  Container contentPane;
	/** Bouton ajouter station */
	JButton btnAjouterStation = new JButton("Ajouter station");
	/** Bouton détail des locations */
	JButton btnLocation = new JButton("Locations");
	/** Bouton ajout d'un client */
	JButton btnAjouterUnClient = new JButton("Ajouter un client");
	/** Bouton suppression d'un client */
	JButton btnSupprimerUnClient = new JButton("Supprimer un Client");
	/** Bouton Louer un vélo */
	JButton btnLouerUnVlo = new JButton("Louer un v\u00E9lo");
	/** Bouton Rendre un vélo */
	JButton btnRendreUnVlo = new JButton("Rendre un v\u00E9lo");
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainFrame frame = new MainFrame();
					frame.setSize(800, 600);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}


	/**
	 * Create the main frame.
	 */
	public MainFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 600);
		setSize(800,600);
		setVisible(true);
		setResizable(false);

		// Set logo nimes
		try{
		java.awt.Image ico = java.awt.Toolkit.getDefaultToolkit().getImage(getClass().getResource("/nimes.png"));
		
		setIconImage(ico);
		} catch (Exception ex){
			System.out.println("Exception: "+ex.getMessage());
			ex.printStackTrace();
		}
				
		
		contentPane = getContentPane();
		Map map = new Map();
		map.setSize(800, 600);
		contentPane.add(map, BorderLayout.CENTER);
		
		JPanel buttons_bas = new JPanel();
		contentPane.add(buttons_bas, BorderLayout.SOUTH);
		buttons_bas.setBackground(new Color(240, 230, 140));
		
		
		btnAjouterStation.setForeground(new Color(0, 128, 0));	
		buttons_bas.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		buttons_bas.add(btnAjouterStation);
		
		
		btnAjouterUnClient.setForeground(new Color(0, 128, 0));
		buttons_bas.add(btnAjouterUnClient);
		

		btnSupprimerUnClient.setForeground(new Color(128, 0, 0));
		buttons_bas.add(btnSupprimerUnClient);
		
		btnLouerUnVlo.setForeground(new Color(0, 0, 128));
		buttons_bas.add(btnLouerUnVlo);
		
		btnRendreUnVlo.setForeground(new Color(0, 0, 128));
		buttons_bas.add(btnRendreUnVlo);
		buttons_bas.add(btnLocation);
		
		//  Listeners
		btnAjouterStation.addActionListener(new MainFrame_BtnListener(this,map));
		btnLocation.addActionListener(new MainFrame_BtnListener(this));
		btnAjouterUnClient.addActionListener(new MainFrame_BtnListener(this));
		btnSupprimerUnClient.addActionListener(new MainFrame_BtnListener(this));
		btnLouerUnVlo.addActionListener(new MainFrame_BtnListener(this));
		btnRendreUnVlo.addActionListener(new MainFrame_BtnListener(this));
		// Fin Test
		
		pack();
	}

	/**
	 * Getter du bouton ajout de station
	 * @return BtnAjouterStation
	 */
	public JButton getBtnAjouterStation() {
		return btnAjouterStation;
	}
	/**
	 * Getter du bouton détail des locations
	 * @return BtnLocation
	 */
	public JButton getBtnLocation() {
		return btnLocation;
	}

	/**
	 * Getter du bouton ajout de client
	 * @return BtnAjouterUnClient
	 */
	public JButton getBtnAjouterUnClient() {
		return btnAjouterUnClient;
	}

	/**
	 * Getter du bouton suppression de client
	 * @return BtnSupprimerUnCLient
	 */
	public JButton getBtnSupprimerUnClient() {
		return btnSupprimerUnClient;
	}

	/**
	 * Getter du bouton louer un vélo
	 * @return BtnLouerUnVlo
	 */
	public JButton getBtnLouerUnVlo() {
		return btnLouerUnVlo;
	}

	/**
	 * Getter du bouton rendre un vélo
	 * @return BtnRendreUnVlo
	 */
	public JButton getBtnRendreUnVlo() {
		return btnRendreUnVlo;
	}




}